import { StringOrNull } from '../Types';
import { IValidator } from './IValidator';


/**
 * 验证字符串长度是否满足要求。
 * 1. 字符串为null 时返回 false
 * 2. 字符串长度小于指定长度时返回 false
 */
export class MinLengthValidator implements IValidator<StringOrNull> {
    private minLength: number;
    constructor(minLength: number) {
        this.minLength = minLength;
    }
    public IsValid(input: StringOrNull): boolean {
        if (!input) {
            return false;
        }
        return input.length >= this.minLength;
    }
}